module.exports = function(grunt){
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        clean: {
            build: ['dist/*']
        },
        // concat: {
        //     options: {
        //         separator: ';',
        //         banner: '/*前置描述*/\r\n',
        //         footer: '\r\n/*后置描述*/',
        //     },
        //     dist: {
        //         src: ['src/js/*.js'],
        //         dest: 'dist/js/app.js'
        //     }
        // },
        uglify: {
            my_target: {
                files: {
                    'dist/js/app.min.js': ['src/js/*.js']
                }
            }
        },
        jshint: {
            options: {
                jshintrc : '.jshintrc' //指定配置文件
            },
            build : ['gruntfile.js', 'src/js/*.js']
        },
        cssmin: {
            options: {
                shorthandCompacting: false, // 开始压缩
                roundingPrecision: -1 // 精确度-1
            },
            target: {
                files: {
                    'dist/css/app.min.css': ['src/css/*.css','src/less/*.css']
                }
            }
        },
        htmlmin: {
            dist: {
                options: {
                    removeComments: true,
                    collapseWhitespace: true
                },
                files: {
                    'dist/index.html': 'src/index.html'
                }
            }
        },
        watch : {
            scripts : {
                files : ['src/js/*.js', 'src/css/*.css'],
                tasks : ['concat', 'jshint', 'uglify', 'cssmin'],
                options : {spawn : false}
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-htmlmin');
    grunt.loadNpmTasks('grunt-contrib-watch');

    grunt.registerTask('html', [ 'clean', 'htmlmin']);
    grunt.registerTask('default', [ 'uglify', 'jshint', 'cssmin']);
    grunt.registerTask('server',['default','watch']);
};